package com.been.common.service.impl;

import java.io.Serializable;
import java.util.List;

import com.been.common.dao.GenericDAO;
import com.been.common.model.BaseModel;
import com.been.common.page.PageInfo;
import com.been.common.service.GenericService;

/**
 * 通用泛型SERVICE实现类
 * @author been
 * @param <T>
 * 2011-10-02
 */
public class GenericServiceImpl<T extends BaseModel> extends PublicServiceImpl implements
		GenericService<T> {
	
	/**
	 * 通用泛型数据访问接口
	 */
	private GenericDAO<T> genericDAO;

	/* (non-Javadoc)
	 * @see com.been.common.service.GenericService#findByPage(java.lang.String, java.lang.Object[], com.been.common.page.PageInfo)
	 */
	public List<T> findByPage(String queryString, Object[] parameters,
			PageInfo pageInfo) {
		return this.genericDAO.findByPage(queryString, parameters, pageInfo);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.GenericService#findByQuery(java.lang.String, java.lang.Object[])
	 */
	public List<T> findByQuery(String queryString, Object[] parameters) {
		return this.genericDAO.findByQuery(queryString, parameters);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.GenericService#findById(java.io.Serializable)
	 */
	public T findById(Serializable id) {
		return this.genericDAO.findById(id);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.GenericService#deleteByIds(java.lang.String)
	 */
	public int deleteByIds(String ids) {
		return this.genericDAO.deleteByIds(ids);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.GenericService#findByExample(com.been.common.model.BaseModel)
	 */
	public List<T> findByExample(T instance) {
		return this.genericDAO.findByExample(instance);
	}

	public GenericDAO<T> getGenericDAO() {
		return genericDAO;
	}

	public void setGenericDAO(GenericDAO<T> genericDAO) {
		super.setPublicDAO(genericDAO);
		this.genericDAO = genericDAO;
	}
}
